package com.atguigu.yygh.common.result;

import cn.hutool.core.util.StrUtil;

import java.util.HashMap;
import java.util.Map;

public class CoReturnFormat {

    public static Map<String,String> messageMap = new HashMap<String, String>();

    static {

        //===============================SYS==================================================
        put(CoReturnFormat.SUCCESS, "成功");
        put(CoReturnFormat.ERROR, "失败");
        put(CoReturnFormat.PERMISSION_DENIED, "Token验证失败");
        put(CoReturnFormat.NO_TOKEN_REQUEST, "无token，请重新登录");
        put(CoReturnFormat.PARAM_ERROR, "参数错误");
        put(CoReturnFormat.DEL_ERROR, "删除失败，请稍后尝试");
        put(CoReturnFormat.SING_ERROR, "签名错误");
        put(CoReturnFormat.TIME_NO, "当前时间不可预约");
        put(CoReturnFormat.CANCEL_ORDER_NO, "当前时间不可取消预约");

        //======================================用户管理=================================================
        put(CoReturnFormat.NO_USER_EXIST, "用户不存在");
        put(CoReturnFormat.USERNAME_OR_PASSWORD_ERROR, "用户名或密码错误");
        put(CoReturnFormat.USER_NOLOGIN, "用户未登录");
        put(CoReturnFormat.USERNAME_EXIST, "用户名已存在");
        put(CoReturnFormat.CODE_ERROR, "验证码错误");
        put(CoReturnFormat.TOKEN_ERROR, "token验证失败");
        put(CoReturnFormat.USER_IS_STOP_USE, "用户已停用");
        put(CoReturnFormat.PHONE_EXIST, "手机号已注册");
        put(CoReturnFormat.EMAIL_EXIST, "邮箱已注册");
        put(CoReturnFormat.LOGIN_SUCCESS, "登录成功");
        put(CoReturnFormat.UPDATE_SUCCESS, "更新成功");
        put(CoReturnFormat.UPDATE_ERROR, "更新失败");
        put(CoReturnFormat.PASSWORD_ERROR, "密码错误");
        put(CoReturnFormat.EXCEL_IMPORT_ERROR, "Excel表格导入失败");
        put(CoReturnFormat.PHONE_IS_ERROR, "手机号格式错误");
        put(CoReturnFormat.EMAIL_IS_ERROR, "邮箱格式错误");

        //======================================医院设置管理=================================================
        put(CoReturnFormat.HOSP_EXIST, "医院已存在");
        put(CoReturnFormat.NO_HOSP_EXIST, "医院不存在");
        put(CoReturnFormat.HOSP_CODE_EXIST, "医院编号错误");


    }


    /**
     * 获取业务返回码信息
     *
     * @param code - String
     * @return String
     */
    public static String getMessage(String code) {
//    	String message = "业务编码未定义: " + code;
        String obj = messageMap.get(code);
        return obj==null ? code : obj;
    }

    /**
     * 返回码放入map中
     *
     * @param m
     */
    public static void putAll(Map<String,String> m) {
        messageMap.putAll(m);
    }

    /**
     * 放入到map中
     */
    public static void put(String key, String value) {
        if(StrUtil.isEmpty(key) || StrUtil.isEmpty(value)) {
            return;
        }
        messageMap.put(key, value);
    }

    //===============================SYS==================================================
    //  成功
    public static final String SUCCESS = "200";

    //  失败
    public static final String ERROR = "400";

    //  Token验证失败
    public static final String PERMISSION_DENIED = "1001";

    //  无token，请重新登录
    public static final String NO_TOKEN_REQUEST = "1002";

    //  参数错误
    public static final String PARAM_ERROR = "600";

    //  删除失败
    public static final String DEL_ERROR = "601";

    //当前时间不可预约
    public static final String TIME_NO = "602";

    //当前时间不可取消预约
    public static final String CANCEL_ORDER_NO = "603";

    //======================================用户管理=================================================
    //  用户不存在
    public static final String NO_USER_EXIST = "10001";

    //  账号密码错误
    public static final String USERNAME_OR_PASSWORD_ERROR = "10002";

    public static final String USER_NOLOGIN = "208";

    //  用户名已存在
    public static final String USERNAME_EXIST = "10003";

    //验证码错误
    public static final String CODE_ERROR = "10015";

    //  token验证失败
    public static final String TOKEN_ERROR = "10004";

    //  用户已停用
    public static final String USER_IS_STOP_USE = "10005";

    //  手机号已注册
    public static final String PHONE_EXIST = "10006";

    //  邮箱已注册
    public static final String EMAIL_EXIST = "10007";

    //  登录成功
    public static final String LOGIN_SUCCESS = "10008";

    //  更新成功
    public static final String UPDATE_SUCCESS = "10009";

    //  更新失败
    public static final String UPDATE_ERROR = "10010";

    //  更新失败
    public static final String PASSWORD_ERROR = "10011";

    //  更新失败
    public static final String EXCEL_IMPORT_ERROR = "10012";

    //  手机号格式不对
    public static final String PHONE_IS_ERROR = "10013";

    //  邮箱格式不对
    public static final String EMAIL_IS_ERROR = "10014";


    //===========================Hosp医院=================================
    //  医院已存在
    public static final String HOSP_EXIST = "11000";

    //  字典不存在
    public static final String NO_HOSP_EXIST = "11001";

    //签名错误
    public static final String SING_ERROR = "11002";

    //医院编号错误
    public static final String HOSP_CODE_EXIST = "11003";



}
